VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsTempTableInsert"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit
Public Function InsertTempInfo(ByVal nComID As String, _
                                ByVal nUserID As String, _
                                ByVal sMoreThanOne As String, _
                                ByVal sEmailTo As String, _
                                ByVal nIncomeTaxReferenceNo As String, _
                                ByVal sNoTaxRefNoRsn As String, _
                                ByVal sNoTaxRefNoText As String, _
                                ByVal nRSAID As String, _
                                ByVal sOtherID As String, _
                                ByVal sSurname As String, _
                                ByVal sFirstNames As String, _
                                ByVal sInitials As String, _
                                ByVal dtBirthDate As String, _
                                ByVal sHome1 As String, ByVal sHome2 As String, ByVal sHome3 As String, ByVal sHome4 As String, _
                                ByVal sHomeCode As String, _
                                ByVal sPost1 As String, ByVal sPost2 As String, ByVal sPost3 As String, ByVal sPost4 As String, _
                                ByVal sPostCode As String, _
                                ByVal sFormType As String, _
                                ByVal nFundID As String, _
                                ByVal nEmpID As String) As Double
                                'ByVal nFundPAYERefNum As String) As Double
                                
    
    Dim cnInsertTempInfo As ADODB.Connection
    
    Dim rsHolder As ADODB.recordSet
    Dim nSeqNo As Double
    Dim cmd As ADODB.Command
    Set cnInsertTempInfo = New ADODB.Connection
    
    
    Set cmd = New ADODB.Command 'CreateObject("ADODB.COMMAND")
    
    With cnInsertTempInfo
        .ConnectionString = GetConnectionString() 'Johann (20090625): Centralised code for connection string added
        .Open
    End With
    
    Set rsHolder = New ADODB.recordSet
    
    '-------------------------------------------
    
    cmd.CommandText = "dir_insert_dir_temp_request"
    cmd.CommandType = adCmdStoredProc
    Set cmd.ActiveConnection = cnInsertTempInfo
    
        cmd.Parameters.Append cmd.CreateParameter("com_id", adDouble, adParamInput, , IIf(nComID = "", Null, CDbl(Val(nComID))))
        cmd.Parameters.Append cmd.CreateParameter("use_id", adDouble, adParamInput, , IIf(nUserID = "", Null, CDbl(Val(nUserID))))
        
        cmd.Parameters.Append cmd.CreateParameter("more_than_one", adVarChar, adParamInput, 1, IIf(sMoreThanOne = "", Null, sMoreThanOne))
        cmd.Parameters.Append cmd.CreateParameter("email_to", adVarChar, adParamInput, 80, IIf(sEmailTo = "", Null, sEmailTo))
        cmd.Parameters.Append cmd.CreateParameter("income_tax_reference_number", adDouble, adParamInput, , IIf(nIncomeTaxReferenceNo = "", Null, CDbl(Val(nIncomeTaxReferenceNo))))
        cmd.Parameters.Append cmd.CreateParameter("no_tax_ref_no_rsn", adVarChar, adParamInput, 2, IIf(sNoTaxRefNoRsn = "", Null, sNoTaxRefNoRsn))
        cmd.Parameters.Append cmd.CreateParameter("no_tax_ref_no_text", adVarChar, adParamInput, 64, IIf(sNoTaxRefNoText = "", Null, sNoTaxRefNoText))
        
        cmd.Parameters.Append cmd.CreateParameter("rsa_id_number", adDouble, adParamInput, , IIf(nRSAID = "", Null, CDbl(Val(nRSAID))))
        
        cmd.Parameters.Append cmd.CreateParameter("other_id_number", adVarChar, adParamInput, 15, IIf(sOtherID = "", Null, sOtherID))
        cmd.Parameters.Append cmd.CreateParameter("surname", adVarChar, adParamInput, 120, IIf(sSurname = "", Null, sSurname))
        cmd.Parameters.Append cmd.CreateParameter("firstnames", adVarChar, adParamInput, 90, IIf(sFirstNames = "", Null, sFirstNames))
        cmd.Parameters.Append cmd.CreateParameter("initials", adVarChar, adParamInput, 5, IIf(sInitials = "", Null, sInitials))
        cmd.Parameters.Append cmd.CreateParameter("birthdate", adVarChar, adParamInput, 8, IIf(dtBirthDate = "", Null, dtBirthDate))
        'cmd.Parameters.Append cmd.CreateParameter("birthdate", adDBTimeStamp, adParamInput, , IIf(dtBirthDate = "", Null, DateSerial(Left$(dtBirthDate, 4), Mid$(dtBirthDate, 5, 2), Right$(dtBirthDate, 2))))
        
        cmd.Parameters.Append cmd.CreateParameter("home_addr_l1", adVarChar, adParamInput, 35, IIf(sHome1 = "", Null, sHome1))
        cmd.Parameters.Append cmd.CreateParameter("home_addr_l2", adVarChar, adParamInput, 35, IIf(sHome2 = "", Null, sHome2))
        cmd.Parameters.Append cmd.CreateParameter("home_addr_l3", adVarChar, adParamInput, 35, IIf(sHome3 = "", Null, sHome3))
        cmd.Parameters.Append cmd.CreateParameter("home_addr_l4", adVarChar, adParamInput, 35, IIf(sHome4 = "", Null, sHome4))
        cmd.Parameters.Append cmd.CreateParameter("home_postal_code", adVarChar, adParamInput, 5, IIf(sHomeCode = "", Null, sHomeCode))
        
        cmd.Parameters.Append cmd.CreateParameter("post_addr_l1", adVarChar, adParamInput, 35, IIf(sPost1 = "", Null, sPost1))
        cmd.Parameters.Append cmd.CreateParameter("post_addr_l2", adVarChar, adParamInput, 35, IIf(sPost2 = "", Null, sPost2))
        cmd.Parameters.Append cmd.CreateParameter("post_addr_l3", adVarChar, adParamInput, 35, IIf(sPost3 = "", Null, sPost3))
        cmd.Parameters.Append cmd.CreateParameter("post_addr_l4", adVarChar, adParamInput, 35, IIf(sPost4 = "", Null, sPost4))
        cmd.Parameters.Append cmd.CreateParameter("post_postal_code", adVarChar, adParamInput, 10, IIf(sPostCode = "", Null, sPostCode))
        
        cmd.Parameters.Append cmd.CreateParameter("scod_form_type", adVarChar, adParamInput, 8, IIf(sFormType = "", Null, sFormType))
        
        cmd.Parameters.Append cmd.CreateParameter("fun_id", adDouble, adParamInput, , IIf(nFundID = "", Null, CDbl(Val(nFundID))))
        cmd.Parameters.Append cmd.CreateParameter("emp_id", adDouble, adParamInput, , IIf(nEmpID = "", Null, CDbl(Val(nEmpID))))
        
        'Tina: 2004/03/12
        'cmd.Parameters.Append cmd.CreateParameter("fund_paye_ref_num", adDouble, adParamInput, , IIf(nFundPAYERefNum = "", Null, CDbl(Val(nFundPAYERefNum))))
        
        cmd.Parameters.Append cmd.CreateParameter("temp_seq_num", adDouble, adParamOutput)
        
        
        
    cmd.Execute
    
    nSeqNo = cmd.Parameters.Item("temp_seq_num").Value
        
PROC_EXIT:
  InsertTempInfo = nSeqNo
  
    cnInsertTempInfo.Close
    Set cnInsertTempInfo = Nothing

  Exit Function
  
PROC_ERROR:
  nSeqNo = 0
  Err.Raise Err.Number, "InsertTempInfo", _
            "Failed to insert into dir_temp_request." & vbCrLf & _
            "Description: " & Err.Description
  GoTo PROC_EXIT

End Function

Public Function InsertVendorResponseData(ByVal sUserID As Variant, _
                                         ByVal sRefNo As Variant, _
                                         ByVal sResponseAD As Variant, _
                                         ByVal sDuplicateYN As Variant, _
                                         ByVal sName As Variant, _
                                         ByVal nAmount As Variant) As Integer
                                
    
    Dim objConn As ADODB.Connection
    Dim cmd As ADODB.Command
    Dim nRespID As Integer
    
    On Error GoTo PROC_ERROR
    
    Set objConn = New ADODB.Connection
    With objConn
        .CursorLocation = adUseClient
        .ConnectionString = GetConnectionString() 'Johann (20090625): Centralised code for connection string added
        .Open
    End With
    
    Set cmd = New ADODB.Command
    With cmd
        .CommandText = "dir_insert_vendor_response_data"
        .CommandType = adCmdStoredProc
    Set .ActiveConnection = objConn
    
        .Parameters.Append .CreateParameter("vendor_user_ID", adVarChar, adParamInput, 50, CStr(sUserID))
        .Parameters.Append .CreateParameter("ref_no", adVarChar, adParamInput, 25, CStr(sRefNo))
        .Parameters.Append .CreateParameter("response", adVarChar, adParamInput, 16, CStr(sResponseAD))
        .Parameters.Append .CreateParameter("duplicate", adVarChar, adParamInput, 9, CStr(sDuplicateYN))
        .Parameters.Append .CreateParameter("cardholder_name", adVarChar, adParamInput, 120, CStr(sName))
        .Parameters.Append .CreateParameter("amount", adVarChar, adParamInput, 50, CStr(nAmount))
        .Parameters.Append .CreateParameter("ven_resp_ID", adInteger, adParamOutput, , nRespID)
        
    End With
    
    cmd.Execute
    
    nRespID = cmd.Parameters.Item("ven_resp_ID").Value
    InsertVendorResponseData = CInt(nRespID)
        
PROC_EXIT:

    'Cleanup
    objConn.Close
    

  Exit Function
  
PROC_ERROR:
  Err.Raise Err.Number, "InsertTempInfo", _
            "Failed to insert into dir_vendor_response_data." & vbCrLf & _
            "Description: " & Err.Description
  GoTo PROC_EXIT

End Function 'InsertVendorResponseData
Public Function UpdateVendorResponseData(ByVal nVenRespID As Variant, ByVal nReqNo As Variant)
                                
    
    Dim objConn As ADODB.Connection
    Dim cmd As ADODB.Command
    On Error GoTo PROC_ERROR
    
    
    Set objConn = New ADODB.Connection
    With objConn
        .CursorLocation = adUseClient
        .ConnectionString = GetConnectionString() 'Johann (20090625): Centralised code for connection string added
        .Open
    End With
    
    Set cmd = New ADODB.Command
    With cmd
        .CommandText = "dir_update_vendor_response_data"
        .CommandType = adCmdStoredProc
    Set .ActiveConnection = objConn
    
        .Parameters.Append .CreateParameter("ven_resp_ID", adInteger, adParamInput, , CInt(nVenRespID))
        .Parameters.Append .CreateParameter("req_seq_num", adVarChar, adParamInput, 50, CStr(nReqNo))
        
    End With
    
    cmd.Execute
    
        
PROC_EXIT:
    'Cleanup
    objConn.Close
    
    Exit Function
 
PROC_ERROR:
  Err.Raise Err.Number, "UpdateVendorResponseData", _
            "Failed to update dir_vendor_response_data." & vbCrLf & _
            "Description: " & Err.Description
  GoTo PROC_EXIT

End Function 'UpdateVendorResponseData



